package com.xzx.spark.core.simulation

import java.io.ObjectOutputStream
import java.net.Socket

/**
 *
 * ${DESCRIPTION}
 *
 * @author xinzhixuan
 * @version 1.0
 * @date 2021-12-25 2:00 PM
 */
object Driver {
  def main(args: Array[String]): Unit = {
    val rdd = new RDD()
    // 作为客户端给executor发送数据
    val client = new Socket("localhost", 9999)
    val objectOutputStream = new ObjectOutputStream(client.getOutputStream)
    val task = new Task()
    task.data = rdd.data.take(2)
    task.logic = rdd.logic
    objectOutputStream.writeObject(task)
    objectOutputStream.close()
    client.close()

    // 作为客户端给executor发送数据
    val client2 = new Socket("localhost", 8888)
    val objectOutputStream2 = new ObjectOutputStream(client2.getOutputStream)
    val task2 = new Task()
    task2.data = rdd.data.takeRight(2)
    task2.logic = rdd.logic
    objectOutputStream2.writeObject(task2)
    objectOutputStream2.close()
    client2.close()

  }

}
